﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SelectOperator.aspx.cs" Inherits="CommonPages_SelectOperator" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
    <style type="text/css">
        .no-Icon
        {
            display: none;
        }
    </style>

    <script type="text/javascript" src="../JavaScript/Common.js"></script>

    <script type="text/javascript">
     function nodeLoad(node)  
     {
        Ext.net.DirectMethods.NodeLoad(node.id,node.getUI().isChecked(), {
            success: function(result) {
                var data = eval("(" + result + ")");
                node.loadNodes(data);
            },
            failure: function(errorMsg) {
                Ext.Msg.alert('Failure', errorMsg);
            }
        }); 
    }
    function ConfirmClose() {
        Ext.net.DirectMethods.GetUserNameIds({
            success: function(result) {
                if (result != "") {
                    var strArr = result.split(';');
                    if (strArr[2] != ",") {
                        var controlIds = strArr[2].split(',');
                        parent.Ext.getCmp(controlIds[0]).setValue(strArr[0]);
                        parent.Ext.getCmp(controlIds[1]).setValue(strArr[1]);
                    } else {
                        parent.GetSeledUserNameIdStr(strArr);
                    }
                } else {
                    parent.GetSeledUserNameIdStr("");
                }
                Closepopwin();
            }
        });
    }
    function AddUser()
    {
      extHid_UserIds.value = getCheckedNode();
      extBtn_AddUsers.fireEvent("click","");
    }
   function getCheckedNode() {
        var result = "";
        var checkeds = Ext.getCmp('TreePanel1').getChecked();
        for (var i = 0; i < checkeds.length; i++) {
            result = result + checkeds[i].id + ";";
        }
        result=result.substring(0,result.length-1)
        return result;
    }
    
    </script>

</head>
<body style="background-color: #d5e1f1;">
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <table width="100%" border="0" style="height: 310px;">
        <tr>
            <td style="width: 48%;" valign="top">
                <ext:Panel ID="Panel1" runat="server" Height="310" Border="false" Layout="Fit">
                    <Content>
                        <%--<ext:FitLayout ID="FitLayout1" runat="server">--%>
                            <ext:TreePanel ID="TreePanel1" runat="server" Lines="true" Border="false" BodyStyle="background-color:#f0f0f0;"
                                CollapseFirst="false" AutoScroll="true" ContainerScroll="true">
                                <%--   <Root>
                                    <ext:AsyncTreeNode NodeID="-1" Text="Root" />
                                </Root>--%>
                                <Listeners>
                                    <BeforeLoad Fn="nodeLoad" />
                                    <CheckChange Fn="checkNode" />
                                </Listeners>
                            </ext:TreePanel>
                        <%--</ext:FitLayout>--%>
                    </Content>
                </ext:Panel>
            </td>
            <td style="width: 10%;" valign="middle">
                <table border="0">
                    <tr>
                        <td>
                            <ext:Button ID="extBtn_Add" runat="server" Text="－＞">
                                <Listeners>
                                    <Click Fn="AddUser" />
                                </Listeners>
                            </ext:Button>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <ext:Button ID="extBtn_Delete" runat="server" Text="删除">
                                <DirectEvents>
                                    <Click OnEvent="DelUser_Click">
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 42%;" valign="top">
                <ext:Store ID="Store1" runat="server" AutoLoad="true">
                    <Reader>
                        <ext:JsonReader IDProperty="USER_ID">
                            <Fields>
                                <ext:RecordField Name="USER_ID" />
                                <ext:RecordField Name="USER_NAME" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
                <ext:Panel ID="Panel2" runat="server" Height="310" Width="170" Border="false" Layout="Fit">
                    <Content>
                        <%--<ext:FitLayout ID="FitLayout2" runat="server">--%>
                            <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true"
                                TrackMouseOver="true">
                                <ColumnModel runat="server">
                                    <Columns>
                                        <ext:Column ColumnID="USER_ID" Header="用户编号" DataIndex="USER_ID" Width="60" />
                                        <ext:Column Header="用户名称" DataIndex="USER_NAME" Width="75">
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                    <ext:CheckboxSelectionModel  runat="server">
                                        <CustomConfig>
                                            <ext:ConfigItem Name="checkOnly1" Value="true" Mode="Raw" />
                                        </CustomConfig>
                                    </ext:CheckboxSelectionModel>
                                </SelectionModel>
                                <LoadMask ShowMask="true" />
                            </ext:GridPanel>
                        <%--</ext:FitLayout>--%>
                    </Content>
                </ext:Panel>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="height: 10px;">
            </td>
        </tr>
        <tr>
            <td style="width: 100%;" colspan="3" align="center">
                <table>
                    <tr>
                        <td>
                            <ext:Button ID="btnSave" runat="server" Text="确定" Icon="Disk">
                                <Listeners>
                                    <Click Fn="ConfirmClose" />
                                </Listeners>
                            </ext:Button>
                        </td>
                        <td>
                            <ext:Button ID="btnCancel" runat="server" Text="关闭" Icon="Cancel">
                                <Listeners>
                                    <Click Fn="Closepopwin" />
                                </Listeners>
                            </ext:Button>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <ext:Hidden ID="extHid_UserIds" runat="server" Text="">
    </ext:Hidden>
    <ext:Button ID="extBtn_AddUsers" runat="server" Hidden="true">
        <Listeners>
            <Click Handler="Ext.net.DirectMethods.refrashDataEvent(#{extHid_UserIds}.value);" />
        </Listeners>
    </ext:Button>
    </form>
</body>
</html>
